/**
* @author 愚人码头
* 类似于新浪微博新消息提示的定位框
* 更多http://www.css88.com/archives/3515
*/
(function ($) {
    $.fn.capacityFixed = function (options) {
        var opts = $.extend({}, $.fn.capacityFixed.deflunt, options);
        var FixedFun = function (element) {
            var top = opts.top;
            var right = opts.pageWidth ? ($(window).width() - opts.pageWidth) / 2 + opts.right : opts.right;
            element.css({
                "right": right,
                "top": top
            });
            $(window).resize(function () {
                var right = opts.pageWidth ? ($(window).width() - opts.pageWidth) / 2 + opts.right : opts.right;
                element.css({
                    "right": right
                });
            });
            $(window).scroll(function () {
                var scrolls = $(this).scrollTop();
                if (scrolls > top) {

                    if (window.XMLHttpRequest) {
                        element.css({
                            position: "fixed",
                            top: 0
                        });
                    } else {
                        element.css({
                            top: scrolls
                        });
                    }
                } else {
                    element.css({
                        position: "absolute",
                        top: top
                    });
                }
            });
            element.find(".close-ico").click(function (event) {
                element.hide();
                SoDaoNotify.NoticeClear(); //清除全部消息，sodao.notify.js
                event.preventDefault();
                //
            })
        };
        return $(this).each(function () {
            FixedFun($(this));
        });
    };
    $.fn.capacityFixed.deflunt = {
        right: 100, //相对于页面宽度的右边定位
        top: 100,
        pageWidth: 960
    };
})(jQuery);